<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:url('AdminOrder/index')}">{:lang('TENANT_USER_INDEX')}</a></li>
		</ul>
        <form class="well form-inline margin-top-20" method="get" action="{:url('AdminOrder/index')}">
            商户名:
            <input type="text" class="form-control" name="keywords" style="width: 120px;" value="{:input('request.keywords/s','')}" placeholder="请输入商户名">
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:url('AdminOrder/index')}">清空</a>
        </form>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th width="50">ID</th>
					<th>分类</th>

					<th>商户名</th>
					<th>统一征信码</th>
					<th>地址</th>
					<th>电话</th>
					<th>坐标</th>
					<th>管理员账号</th>
					<th>管理员姓名</th>

                    <th>审核状态</th>
					<th>{:lang('STATUS')}</th>
                    
					<th width="140">{:lang('ACTIONS')}</th>
				</tr>
			</thead>
			<tbody>
				
				<foreach name="list" item="vo">
				<tr>
					<td>{$vo.id}</td>
					<td>
						<foreach name="category" item="ca">
							<if condition="$ca.id eq $vo['category_id']">
								{$ca.name}
							</if>
						</foreach>
					</td>
					<td>{$vo.shop_name}</td>

					<td>
						{$vo.license_id}
					</td>
					<td>{$vo.shop_address}</td>
					<td>
						{$vo.tel}
					</td>
					<td>{$vo.location}</td>
					<td>{$vo.user_login}</td>
					<td>{$vo.user_nickname}</td>
					<td>
						<switch name="vo.checked">
							<case value="0">
								<span class="label label-danger">待审核</span>
							</case>
							<case value="1">
								<span class="label label-success">正常</span>
							</case>
							<case value="2">
								<span class="label label-warning">审核未通过</span>
							</case>
						</switch>
					</td>
					<td>
                        <if condition="$vo['status'] eq 0">
							<span class="label label-danger">关闭</span>
							
						<else />
							<span class="label label-success">正常</span>
                        </if>
                    </td>
					<td>
                        
						<a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('AdminOrder/detail',['id'=>$vo.id])}','商户入驻信息详情',{area: ['1200px', '800px']});">查看资料</a>
						<if condition="$vo['status'] eq 0 && $vo['checked'] eq 1">
                            <span class="btn btn-xs btn-success "><a class="btn btn-xs btn-success js-ajax-dialog-btn" data-msg="确认恢复吗？" href="{:url('AdminIndex/reOpen',array('id'=>$vo['id']))}">恢复开启店铺</a></span>

							<elseif  condition="$vo['status'] eq 1 && $vo['checked'] eq 1">
                            <a class="btn btn-xs btn-danger" onclick="closeShop({$vo.id})">关闭店铺</a>

						</if>
                        <if condition="$vo['checked'] eq 0">
                            <if condition="$vo.user_id eq 0">
								<!-- <a class="btn btn-xs btn-success" href="javascript:parent.openIframeLayer('{:url('AdminOrder/orderAdd',['id'=>$vo.id])}','添加店铺管理员账号密码',{area: ['800px', '600px']});">审核通过</a> -->
								<a class="btn btn-xs btn-success" onclick="addAdmin({$vo.id})">审核通过</a>

								<else/>
								<a class="btn btn-xs btn-success js-ajax-dialog-btn" data-msg="确认审核通过吗？" href="{:url('AdminOrder/checkok',array('id'=>$vo['id']))}">审核通过</a>
							</if>
                            <a class="btn btn-xs btn-danger" onclick="checkno({$vo.id},'{$vo.shop_name}')">不通过</a>
                        </if>
                        
							
						
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>
    <script src="__STATIC__/js/admin.js"></script>
    <script>
        function checkno(id,shop_name){
			layui.use('layer', function(){
			var layer = layui.layer;
			
			layer.prompt({title: '请输入不通过原因', formType: 2}, function(text, index){
				layer.close(index);
				
				$.get("{:url('AdminOrder/checkno')}", 
				{
					id:id,
					shop_name:shop_name,
					msg:text
				}, function(res){
				if(res.code==1){
					layer.msg("驳回成功")
					setTimeout(function(){
						window.location.reload();
					},1000)
				}
				});
			});
			}); 
		}
		
		function addAdmin(id){
			//iframe窗
			layui.use('layer', function(){
				var layer = layui.layer;
				layer.open({
					type: 2,
					title: '添加商户主管理员账号',
					shadeClose: true,
					shade: false,
					maxmin: false, //开启最大化最小化按钮
					area: ['893px', '600px'],
					content: "{:url('AdminOrder/orderAdd')}"+"?id="+id,
					end:function() {
						location.reload();
					}
				});
					
			})
		}
		function closeShop(id){
			layui.use('layer', function(){
			var layer = layui.layer;
			
			layer.prompt({title: '请输入关闭原因', formType: 2}, function(text, index){
				layer.close(index);
				
				$.get("{:url('AdminIndex/close')}", 
				{
					id:id,
					msg:text
				}, function(res){
				if(res.code==1){
					layer.msg("关闭成功")
					setTimeout(function(){
						window.location.reload();
					},1000)
				}
				});
			});
			}); 
		}
    </script>
</body>
</html>